package com.xbao.dao;

import com.xbao.model.PeriodRule;
import com.xbao.model.PeriodRuleExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface PeriodRuleMapper {
    @SelectProvider(type=PeriodRuleSqlProvider.class, method="countByExample")
    int countByExample(PeriodRuleExample example);

    @DeleteProvider(type=PeriodRuleSqlProvider.class, method="deleteByExample")
    int deleteByExample(PeriodRuleExample example);

    @Delete({
        "delete from period_rule",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into period_rule (name, starttime, ",
        "endtime, classtime, ",
        "eid, subid, totaltimes, ",
        "ruletype, cid, orgid, ",
        "comments, feetype, ",
        "alert)",
        "values (#{name,jdbcType=VARCHAR}, #{starttime,jdbcType=BIGINT}, ",
        "#{endtime,jdbcType=BIGINT}, #{classtime,jdbcType=VARCHAR}, ",
        "#{eid,jdbcType=BIGINT}, #{subid,jdbcType=BIGINT}, #{totaltimes,jdbcType=BIGINT}, ",
        "#{ruletype,jdbcType=INTEGER}, #{cid,jdbcType=BIGINT}, #{orgid,jdbcType=BIGINT}, ",
        "#{comments,jdbcType=VARCHAR}, #{feetype,jdbcType=INTEGER}, ",
        "#{alert,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(PeriodRule record);

    @InsertProvider(type=PeriodRuleSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(PeriodRule record);

    @SelectProvider(type=PeriodRuleSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="starttime", property="starttime", jdbcType=JdbcType.BIGINT),
        @Result(column="endtime", property="endtime", jdbcType=JdbcType.BIGINT),
        @Result(column="classtime", property="classtime", jdbcType=JdbcType.VARCHAR),
        @Result(column="eid", property="eid", jdbcType=JdbcType.BIGINT),
        @Result(column="subid", property="subid", jdbcType=JdbcType.BIGINT),
        @Result(column="totaltimes", property="totaltimes", jdbcType=JdbcType.BIGINT),
        @Result(column="ruletype", property="ruletype", jdbcType=JdbcType.INTEGER),
        @Result(column="cid", property="cid", jdbcType=JdbcType.BIGINT),
        @Result(column="orgid", property="orgid", jdbcType=JdbcType.BIGINT),
        @Result(column="comments", property="comments", jdbcType=JdbcType.VARCHAR),
        @Result(column="feetype", property="feetype", jdbcType=JdbcType.INTEGER),
        @Result(column="alert", property="alert", jdbcType=JdbcType.INTEGER)
    })
    List<PeriodRule> selectByExample(PeriodRuleExample example);

    @Select({
        "select",
        "id, name, starttime, endtime, classtime, eid, subid, totaltimes, ruletype, cid, ",
        "orgid, comments, feetype, alert",
        "from period_rule",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="starttime", property="starttime", jdbcType=JdbcType.BIGINT),
        @Result(column="endtime", property="endtime", jdbcType=JdbcType.BIGINT),
        @Result(column="classtime", property="classtime", jdbcType=JdbcType.VARCHAR),
        @Result(column="eid", property="eid", jdbcType=JdbcType.BIGINT),
        @Result(column="subid", property="subid", jdbcType=JdbcType.BIGINT),
        @Result(column="totaltimes", property="totaltimes", jdbcType=JdbcType.BIGINT),
        @Result(column="ruletype", property="ruletype", jdbcType=JdbcType.INTEGER),
        @Result(column="cid", property="cid", jdbcType=JdbcType.BIGINT),
        @Result(column="orgid", property="orgid", jdbcType=JdbcType.BIGINT),
        @Result(column="comments", property="comments", jdbcType=JdbcType.VARCHAR),
        @Result(column="feetype", property="feetype", jdbcType=JdbcType.INTEGER),
        @Result(column="alert", property="alert", jdbcType=JdbcType.INTEGER)
    })
    PeriodRule selectByPrimaryKey(Long id);

    @UpdateProvider(type=PeriodRuleSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") PeriodRule record, @Param("example") PeriodRuleExample example);

    @UpdateProvider(type=PeriodRuleSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") PeriodRule record, @Param("example") PeriodRuleExample example);

    @UpdateProvider(type=PeriodRuleSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(PeriodRule record);

    @Update({
        "update period_rule",
        "set name = #{name,jdbcType=VARCHAR},",
          "starttime = #{starttime,jdbcType=BIGINT},",
          "endtime = #{endtime,jdbcType=BIGINT},",
          "classtime = #{classtime,jdbcType=VARCHAR},",
          "eid = #{eid,jdbcType=BIGINT},",
          "subid = #{subid,jdbcType=BIGINT},",
          "totaltimes = #{totaltimes,jdbcType=BIGINT},",
          "ruletype = #{ruletype,jdbcType=INTEGER},",
          "cid = #{cid,jdbcType=BIGINT},",
          "orgid = #{orgid,jdbcType=BIGINT},",
          "comments = #{comments,jdbcType=VARCHAR},",
          "feetype = #{feetype,jdbcType=INTEGER},",
          "alert = #{alert,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(PeriodRule record);
}